﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wp.BLL;
using Wp.DAL;

public partial class Modules_Comment_CommentDefault : System.Web.UI.Page
{
    public static int PAGE_SIZE = 30;
    public int PageIndex { get; set; }
    protected void Page_Load(object sender, EventArgs e)
    {
        PageIndex = CommonHelper.QueryStringInt("PageIndex", 1);
        if (!IsPostBack)
        {

            //  int numberitemcommet = Wp.BLL.TblOptionManager.CreateInstant().GetOption("number-items-comment").Trim().ToInt();
            List<TblCommentsEntity> ls3 = TblCommentsManager.CreateInstant().SelectByPost(null, null, "approved", 1000);
            int TotalRow = ls3.Count;
            rptComment.DataSource = ls3.Skip((PageIndex - 1) * PAGE_SIZE).Take(PAGE_SIZE); ; ;
            rptComment.DataBind();
            smartPager1.PageSize = PAGE_SIZE;
            smartPager1.QueryStringKey = "PageIndex";
            smartPager1.RowCount = TotalRow;
            smartPager1.NavigatePreviousText = "<<";
            smartPager1.NavigateNextText = ">>";
            smartPager1.Display = 7;
            smartPager1.UrlFormatString = "/comment/trang-{0}.html";
            smartPager1.Visible = TotalRow > PAGE_SIZE;
        }
    }
    public string PostTile(object PostId)
    {
        TblPostsEntity item = TblPostsManager.CreateInstant().SelectOne(PostId.ToInt());
        if (item != null)
            return item.Title;
        return "";
    }

}